package com.baichang.taoshunda.dao.impl;

import org.springframework.stereotype.Repository;

import com.baichang.framework.dao.impl.BaseDaoImpl;
import com.baichang.taoshunda.dao.IdleCollectionDao;
import com.baichang.taoshunda.entity.IdleCollection;

import java.util.Map;

@Repository
public class IdleCollectionDaoImpl extends BaseDaoImpl<IdleCollection> implements IdleCollectionDao {
    /**
     * 查看是否收藏闲置
     *
     * @param idleId
     * @param userId
     * @return
     */
    @Override
    public Map<String, Object> getControllerInfo(Integer idleId, Integer userId) {
        String sql = " SELECT IFNULL(COUNT(*),0) AS collection FROM t_idle_collection WHERE idle_goods_id=? AND user_id= ?";
        return queryForMap(sql, idleId, userId);
    }

    /**
     * 取消收藏
     *
     * @param idleId
     * @param userId
     * @return
     */
    @Override
    public int deleteCollection(Integer idleId, Integer userId) {
        String sql = "idle_goods_id=? AND user_id= ?";
        return delete(sql, idleId, userId);
    }
}